package com.myfactoryMethod;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class PropertiesReader {

	public Map<String, String> getProperties(){
		Properties properties = new Properties();
		Map<String, String> map = new HashMap<>();
	    try {
	    	
	    	InputStream in = getClass().getClassLoader().getResourceAsStream("type.properties");
	    	// 使用ClassLoader加载properties配置文件生成对应的输入流
		    //InputStream in = PropertiesReader.class.getClassLoader().getResourceAsStream("type.properties");
		    // 使用properties对象加载输入流
			//properties.load(in);
			properties.setProperty("huawei", "com.myfactoryMethod.HuaweiPhone");
			properties.setProperty("apple", "com.myfactoryMethod.ApplePhone");
			
			Enumeration en =  properties.propertyNames();
			while (en.hasMoreElements()) {
				String key = (String) en.nextElement();
				//获取key对应的value值
			    String value = properties.getProperty(key);
				map.put(key, value);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	    return map;
	}
}
